package ro.cityprojects.adminloc.entities;

import javax.persistence.*;
import java.util.Set;

@Entity
@Table(name = "CITY")
public class City {

    @Id
    @Column(name = "CITY_ID", nullable = false, insertable = true, updatable = true, length = 0)
    private Integer cityId;

    @Column(name = "NAME", nullable = false, insertable = true, updatable = true, length = 64, precision = 0)
    private String name;

    @ManyToOne(fetch = FetchType.LAZY, targetEntity = County.class, cascade = CascadeType.ALL)
    @JoinColumn(name = "COUNTY_ID", referencedColumnName = "COUNTY_ID", nullable = false)
    private County countyByCountyId;

    @OneToMany(mappedBy = "cityByCityId")
    private Set<Street> streetsByCityId;

    public void setCityId(Integer cityId) {
        this.cityId = cityId;
    }

    public Integer getCityId() {
        return cityId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public County getCountyByCountyId() {
        return countyByCountyId;
    }

    public void setCountyByCountyId(County countyByCountyId) {
        this.countyByCountyId = countyByCountyId;
    }

    public Set<Street> getStreetsByCityId() {
        return streetsByCityId;
    }

    public void setStreetsByCityId(Set<Street> streetsByCityId) {
        this.streetsByCityId = streetsByCityId;
    }
}
